﻿@using Common
@using Models
@model ReqData<Lang>
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<form action="@Url.Action("Index","AddDic",new { area="WebFunction"})" method="post" class="layui-form">
    <fieldset>
        <legend>存入字典</legend>
        <div class="layui-form-item">
            <label class="layui-form-label"> 字 典 </label>
            <div class="layui-input-block">
                <input type="text" name="msgid" required lay-verify="required" placeholder="请输入字典" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </fieldset>
</form>
<table class="layui-table table-center">
    <thead>
        <tr>
            <th>序号</th>
            <th>MsgID</th>
            <th>MsgStr</th>
            <th width="25%">操作</th>
        </tr>
    </thead>
    @{
        foreach (var item in Model.DataList) {
            <tr>
                <td>@item.id</td>
                <td>@item.msgid</td>
                <td>@item.msgstr</td>
                <td>
                    <label class="" onclick="Edit(@item.id,'@item.msgid')">
                        <button class="layui-btn"><i class="layui-icon">&#xe642;</i> 编辑</button>
                    </label>
                    <label class="" onclick="Delete(@item.id)">
                        <button class="layui-btn layui-btn-danger"><i class="layui-icon">&#xe640;</i> 删除</button>
                    </label>
                </td>
            </tr>
        }
    }
</table>
@Html.Raw(Model.PageContent)

<div id="dd" style="display:none;padding:5px;">
    <form action="/AddDic/Index" method="post" class="layui-form">
        <div class="layui-row">
            <div class="layui-col-sm8">
                <input type="hidden" name="id" id="id" />
                <input type="text" name="msgid" id="msgid" required lay-verify="required" placeholder="请输入字典" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-col-sm3 layui-col-sm-offset1">
                <button class="layui-btn layui-btn-block" lay-submit lay-filter="formDemo">修改</button>
            </div>
        </div>
    </form>
</div>

@section jq{
    <script>
        // 删除信息
        function Delete(id) {
            //询问框
            var index = layer.confirm('确认删除？', {
                icon: 3,
                btn: ['确认', '取消'] //按钮
            },
                function () {
                    location.href = "@Url.Action("Delete","AddDic")" + "/" + id;
                },
                function () {
                    layer.close(index);
                }
            );
        }
        // 编辑信息
        function Edit(id,con) {
            //页面层
            layer.prompt({
                formType: 0,
                value: con,
                title: '编辑信息',
            }, function (value, index, elem) {
                $.post("@Url.Action("Edit","AddDic")", { id: id, msgid: value }, function (res) {
                    res = res.replace("<script>", "").replace("<\/script>", "")
                    eval(res);
                });
                layer.close(index);
                }
            );
        }

    </script>
}